package controllers;

import models.Page;
import play.mvc.Controller;
import play.mvc.With;

/**
 * Created by IntelliJ IDEA.
 * User: repnikov
 * Date: 06.08.11
 * Time: 16:22
 * To change this template use File | Settings | File Templates.
 */
@With(UserChecker.class)
public class PageView extends Controller {
    public static void show(String url) {
        Page page =  Page.all()
            .filter("url", url)
            .get();

        if (page == null && !flash.contains("isAdmin")) {
            if (Page.all().count() > 0)
                notFoundIfNull(page, "Page not found");
            else
                redirect("/login");
        }
        render(page, url);
    }
}
